package Queue;

import Stack.ArrayStack;

import java.util.Random;

/**
 * ClassName: Main
 * Package: Array
 *
 * @Author 马学兴
 * @Create 2023/11/30 23:07
 * @Version 1.0
 * Description:
 */
public class Main {
    //测试
    private static double testQueue(Queue<Integer> q,int opCount){
        long startTime = System.nanoTime();
        Random random=new Random();
        for (int i = 0; i < opCount; i++) {
            q.enqueue(random.nextInt(Integer.MAX_VALUE));
        }
        for (int i = 0; i < opCount; i++) {
           q.dequeue();
        }
        long endTime = System.nanoTime();
        return (endTime-startTime)/1000000000.0;

    }
    public static void main(String[] args) {
        int opCount=10000;
        ArrayQueue<Integer> arrayQueue=new ArrayQueue<Integer>();
        double time1 = testQueue(arrayQueue, opCount);
        System.out.println("ArrayQueue, time:"+time1+" s");

        LoopQueue<Integer> loopQueue=new LoopQueue<Integer>();
        double time2 = testQueue(loopQueue, opCount);
        System.out.println("LoopQueue, time:"+time2+" s");
    }
}


